<?php

namespace App\Models\V1;

use Illuminate\Database\Eloquent\Relations\BelongsTo;

class GameVersion extends BaseModel
{

    protected $connection;
    protected $table = 'game_version';

    protected $casts = [
        'channel_id' => 'json'
    ];


    public function getChannelIdAttribute($value)
    {
        return json_decode($value, true);
    }



    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);
        $this->connection = config('database.connections.biqi_game.database');
    }

    public function Evaluating(): BelongsTo
    {
        return $this->belongsTo(Evaluating::class, 'ulid', 'game_id')->where('state', 1);
    }

    public function Product(): BelongsTo
    {
        return $this->belongsTo(Product::class, 'product', 'ulid');
    }

}
